#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
char* longestPalindrome(char* s)
{
    int len = strlen(s);
    int maxstart = 0;
    int maxlen = 0;
    int max;
    if (len == 1)
        return s;
    for (int i = 1; i < len; i++)
    {
        int left = i - 1;
        int right = i + 1;
        max = 1;
        while (left >= 0 && s[left] == s[i])
        {
            left--;
            max++;
        }
        while (right <= len - 1 && s[right] == s[i])
        {
            right++;
            max++;
        }
        while (left >= 0 && right <= len - 1 && s[left] == s[right])
        {
            left--;
            right++;
            max += 2;
        }
        if (max > maxlen)
        {
            maxstart = left + 1;
            maxlen = max;
        }
    }
    s[maxstart + maxlen] = '\0';
    return &s[maxstart];
}
int main()
{
    char a[] = "aba";
    longestPalindrome(a);
	return 0;
}